package com.jh.paymentchannel.payment;

import static io.jsonwebtoken.lang.Strings.hasText;

/**
 * @author Yichuan
 * @version 1.0
 */
public enum OrderType {

    WECHAT(1, "WECHAT", "微信"),

    ALIPAY(2, "ALIPAY", "支付宝"),

    ;

    final short code;
    final String value;
    final String desc;

    OrderType(int code, String value, String desc) {
        this.code = (short) code;
        this.value = value;
        this.desc = desc;
    }

    public short getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static OrderType of(String value) {
        if (!hasText(value)) {
            return null;
        }
        for (OrderType ot: values()) {
            if (ot.getValue().equalsIgnoreCase(value)) {
                return ot;
            }
        }
        return null;
    }
}
